<!--
 * @Author: wcx 1055127249@qq.com
 * @Date: 2024-12-27 10:10:43
 * @LastEditors: wcx 1055127249@qq.com
 * @LastEditTime: 2025-01-17 14:29:23
 * @FilePath: \my-project\src\views\commonBizTable\components\filterForm.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <baseForm ref="baseForm" inline :validator="false" @onSubmit="onSubmit" v-if="visible" />
</template>
<script>
import baseForm from './baseForm'
export default {
  components: {
    baseForm
  },
  data() {
    return {
      visible: false
    }
  },
  methods: {
    async init(table) {
      const { fields = [] } = table || {}
      const formFields = fields.filter(i => i.filter).map(i => ({ ...i, type: i.filterType }))
      this.visible = formFields.length > 0
      await this.$nextTick()
      if (this.visible) this.$refs.baseForm.setFileds(formFields)
    },
    toggleFilter() {
      this.visible = !this.visible
    },
    onSubmit(data) {
      this.$emit('query', data)
    }
  }
}
</script>